#ifndef I_PYTHON_BIND_SERVER_H
#define I_PYTHON_BIND_SERVER_H

#include <QObject>
#include <QString>
#include <pybind11/embed.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

namespace pybind11 {
class object;
class args;
} // namespace pybind11

class IPythonBindServer {
public:
  virtual ~IPythonBindServer() = default;

  // 初始化Python环境
  virtual bool initialize() = 0;
  virtual bool isInitialized() const = 0;

  // 对象注册与管理
  virtual bool registerObject(QObject *obj, const QString &objectId = "",
                              const QString &scriptPath = "") = 0;
  virtual bool unregisterObject(const QString &objectId) = 0;
  virtual bool unregisterObject(QObject *obj) = 0;
  virtual QObject *getObject(const QString &objectId) const = 0;
  virtual QString getObjectId(QObject *obj) const = 0;

  // 脚本管理
  virtual bool loadScript(const QString &objectId,
                          const QString &scriptPath) = 0;
  virtual bool unloadScript(const QString &objectId) = 0;
  virtual bool reloadScript(const QString &objectId) = 0;

  // 属性访问接口
  virtual pybind11::object getProperty(const QString &objectId,
                                       const QString &propertyName) = 0;
  virtual bool setProperty(const QString &objectId, const QString &propertyName,
                           const pybind11::object &value) = 0;

  // 脚本函数执行
  virtual pybind11::object executeFunction(const QString &objectId,
                                           const QString &functionName,
                                           const pybind11::args &args) = 0;

  // 新增的重载方法，不带args参数
  virtual pybind11::object executeFunction(const QString &objectId,
                                           const QString &functionName) = 0;

  // 对象间交互
  virtual pybind11::object getObjectReference(const QString &objectId) = 0;
};

#endif // I_PYTHON_BIND_SERVER_H